# Copyright (c) 2024 Microsoft Corporation.
# Licensed under the MIT License

"""Persona generating module for fine-tuning GraphRAG prompts."""

from graphrag.llm.types.llm_types import CompletionLLM
from graphrag.prompt_tune.prompt import TRANSLATE_PROMPT


async def translate_text(
    llm: CompletionLLM, text: str, language: str
) -> str:
    """Generate an LLM persona to use for GraphRAG prompts.

    Parameters
    ----------
    - llm (CompletionLLM): The LLM to use for generation
    - text (str): The text to translate for
    - language (str): The language to translate for
    """
    translate_prompt = TRANSLATE_PROMPT.format(
        input_text=text, language=language
    )

    response = await llm(translate_prompt)

    return str(response.output)
